{include file="public/header" /}
<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-tab-content">
            <form id="formData" class="layui-form layui-form-pane" autocomplete="off">
                <div class="layui-form-item">
                    <label class="layui-form-label layui-required">年份</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="year" id="year" value="{$info.year}" placeholder="请选择年份">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">内容</label>
                    <div class="layui-input-block">
                        <textarea name="content" id="content" value="{$info.sort}" placeholder="请输入内容，使用 | 进行分隔" class="layui-textarea"></textarea>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">排序</label>
                    <div class="layui-input-block">
                        <input type="text" name="sort" id="sort" value="{$info.sort}" class="layui-input" placeholder="请输入排序，数字越小，排序越靠前">
                    </div>
                </div>


                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <!--<button type="submit" lay-submit lay-filter="add" class="layui-btn layui-btn-normal">提交</button>-->
                        <button type="button" onclick="sendFormData()" class="layui-btn layui-btn-normal">提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>

<script>
    layui.use(['form','laydate'],function () {
        var $ = layui.jquery,
            form = layui.form,
            laydate = layui.laydate;

        laydate.render({
            elem: '#year',
            type: 'year',
            theme: '#1E9FFF'
        });

    });

    function sendFormData() {
        if (emptyCheck($("#year").val())) {
            hintMsg('请选择年份')
            return false
        }

        var historyLoad = layer.load(1,{shade:[0.5,'#FFF'],time:0})
        let data = $("#formData").serialize()
        ajaxRequest("{:url('company/editHistory')}",data,function (res) {
            if (res.code == 'suc'){
                sucMsg(res.msg,function () {
                    //刷新父级页面
                    parent.layui.table.reload('historyList')
                    //关闭遮罩层
                    layer.close(historyLoad)
                    //关闭当前弹出层
                    xadmin.close()
                })

            }else {
                errMsg(res.msg,function () {
                    //关闭遮罩层
                    layer.close(historyLoad)
                })
            }
        })
    }
</script>